package org.zachary.agent.infrastructure.converter;


import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import org.zachary.agent.domain.aggregate_model.user.EncryptedPassword;

@Converter(autoApply = true)
public class PasswordConverter implements AttributeConverter<EncryptedPassword, String> {
    @Override
    public String convertToDatabaseColumn(EncryptedPassword attribute) {
        return attribute != null ? attribute.getValue() : null;
    }

    @Override
    public EncryptedPassword convertToEntityAttribute(String dbData) {
        return dbData != null ? EncryptedPassword.fromEncrypted(dbData) : null;
    }
}